package com.mkono.infra.activity;

import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Toast;

import com.mkono.infra.R;

/**
 * Created by HUANG on 2018/1/22.
 */

public abstract class BaseActivity extends Activity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if(Build.VERSION.SDK_INT >= 21) {
            View decorView = getWindow().getDecorView();
            //让应用主题内容占用系统状态栏的空间,注意:下面两个参数必须一起使用 stable 牢固的
            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            decorView.setSystemUiVisibility(option);
            //设置状态栏颜色为透明
            getWindow().setStatusBarColor(getResources().getColor(R.color.main_view));
        }
    }

    /**
     * 初始化activity控件及其他三方定义
     */
    public void init(){
        initView();
    }

    public abstract void initView();

    /**
     *
     */
    public void showToast(String mes) {
        Toast.makeText(this,mes,Toast.LENGTH_LONG).show();
    }

    public Context getContext(){
        return BaseActivity.this;
    }
}
